<?php
/**
 * @version        $Id$
 * @author         master@xuewl.com
 * @copyright      Copyright (c) 2007 - 2014, Chongqing xuewl Information Technology Co., Ltd.
 * @link           http://www.xuewl.com
**/
namespace Common\Api;
use Common\Api\Api;

class HookApi extends Api{
    /* 构造方法 */
    protected function init(){
        $this->modules = getcache('module', 'commons');
    }

    /* 嵌入点简易实现方法 */
    public function run($hookid, $param = '') {
        if (!$this->modules) return FALSE;
        $modules = array_keys($this->modules);
        foreach ($modules as $module) {
            $hook_file = APP_PATH.$module.'/Library/'.$module.'.hook.class.php';
            if (!file_exists($hook_file)) continue;
            require_once $hook_file;
            $classkey = $module;            
            $Hook = new $classkey();
            if(!method_exists($Hook, $hookid)) continue;
            $Hook->$hookid($param);
        }
    }
}